package pack3;

import People.People;
import course.Course;

public class Student extends People {
    private Course[] StudentCourse;
    private String Major4;
    public Student() {}

    public Student(int ID, String Name, String Gender) {
        this.ID = ID;
        this.Name = Name;
        this.Gender = Gender;
        StudentCourse=new Course[0];
    }

    public boolean choseCourse(Course course) {
        boolean flag = false;
        for (int i = 0; i < this.StudentCourse.length; i++) {
            if (StudentCourse[i] == null) {
                StudentCourse[i] = course;
                flag = true;
                break;
            }
        }
        return flag;
    }

    //学生选课
    public boolean removeCourse(Course course) {
        boolean flag = false;
        for (int i = 0; i < this.StudentCourse.length; i++) {
            if (StudentCourse[i] == course) {
                StudentCourse[i] = null;
                flag = true;
                break;
            }
        }
        return flag;
    }//学生退课
    public void displayCourse(){

        System.out.println("学生"+this.Name+"所选课程有：");
        for(Course c:StudentCourse){
            if(c!=null)
            System.out.print("\n "+c.getCourseID()+" "+c.getCourseName()+" "
                    +c.getClassroom()+" "+c.getTime()+" ");
        }//打印学生课表
    }
    public String getMajor4(){
        return Major4;
    }
    public static void main(String[] args) {
        Student stu1 = new Student();
        System.out.println("stu1 不同包中实例访问父类继承public属性"+stu1.ID);
        System.out.println("stu1 不同包中实例访问子类特有属性"+stu1.Major4);
        System.out.println("stu1 不同包中实例访问父类public方法"+stu1.getID());
        System.out.println("stu1 不同包中实例访问父类继承protected属性"+stu1.Major2);
        //System.out.println("stu1 不同包中实例访问父类继承default属性"+stu1.Major3);
        System.out.println("stu1 不同包中实例访问父类继承protected方法"+stu1.getMajor2());
        Course JAVA= new Course(001,"JAVA","教101","Tuesday Section 1","ZH